package demo1;

public class LeetCode3 {
    public int lengthOfLongestSubstring(String s) {
        char[] arr = s.toCharArray();
        int[] hash = new int[128];
        int n = arr.length , len = -1;
        for(int left = 0, right = 0; right < n ; right++) {
            hash[arr[right]]++;
            while(hash[arr[right]] > 1 ) hash[arr[left++]]--;
            len = Math.max(len , right - left + 1);
        }
        return len == -1 ? 0 : len;
    }
}
